home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
t_os
/
sndadder
/
rec.c
next >
Wrap
Text File
|
1993-07-08
|
6KB
|
245 lines
/*********************************
* 長時間サンプラー Version 1.00 *
* Copyright 1993 by Tetsuo O. *
*********************************/
#pragma On(Align_labels) ;
#include <stdio.h>
#include <stdlib.h>
#include <cdrfrb.h>
#include <string.h>
#include <snd.h>
#include <egb.h>
#define UPPER_FREQ 19200
extern int snd_adder() ;
extern int ext_malloc() ;
struct STRING {
short x ;
short y ;
unsigned short len ;
char str[80] ;
} ;
struct SAMPLING {
char name[8] ;
unsigned int id ;
unsigned int width ;
unsigned int loop_start ;
unsigned int loop_length ;
unsigned short freq ;
unsigned short fix ;
unsigned char onkai ;
unsigned char flug ;
unsigned short dummy ;
} ;
int joy_wait(void)
{
int stk ;
do {
SND_joy_in_2(0,&stk) ;
} while(stk == 0xff) ;
return stk ;
}
void main(argc,argv)
int argc ;
char *argv[] ;
{
FILE *fp ;
char *ework,*swork,*buffer ;
char s_name[80],s2_name[80],para[10],chr[2] ;
int i,k,play_no,buff,cdtype,strack,etrack,freq,f1,f2 ;
struct TIMEADRS t_time[99],d_time,start,stop ;
struct SAMPLING snd ;
char *w_name[2] ;
w_name[0] = "recwork1" ;
w_name[1] = "recwork2" ;
struct STRING msg[5] = {
0, 16, 54,"スーパーであることだよ、長時間サンプラーVer1.00",
0, 32, 17,"メモリの確保中だ。しばし待たれよ。",
0, 64, 54,"目的のCDを入れて、何かボタンを押せっていってんだよ!",
0, 96, 42,"正常終了でぇす。長い待ち時間御苦労様です!",
0,128, 56,"作成出来るファイルは、ディスク容量の半分までですからね。"
} ;
struct STRING error[8] = {
0,447, 44,"TOWNSの構造上、こんなのはムぅリっスよ。",
0,431, 46,"データトラックはサンプリングできねぇよ・・・。",
0,447, 52,"出来るんなら、どうやんのか聞きてーもんだなぁ・・・。",
0,447, 48,"あのぉ、失礼ですけど、そんな番号の曲はないっス。",
0,447, 34,"ディスクの容量が足りないでゴワす。",
0,447, 60,"ディスクの容量が足りん! 残念賞でした。容量増やせよ。なぁ。",
0,447, 60,"原因不明のエラーなんですよ。困った困った。バグです。きっと。", 0,447, 36,"CDが正しくセットされてませんよぉ。"
} ;
if (argc < 3 || argc > 4) {
printf("Usage : run386 REC [CD Number] [FileName] [freq]\n") ;
exit(9) ;
}
if ((ework = malloc(1536 + 16384)) == NULL) {
printf("メモリが不足しているザンス。") ;
printf("しかも、約16kBの不足ザマす。何に使ってるかは知らんけど、\n") ;
printf("普通の状態で立ち上げることをお勧めする。") ;
exit(9) ;
}
swork = ework + 1536 ;
EGB_init(ework,1536) ;
EGB_resolution(ework,0,3) ;
EGB_writePage(ework,0) ;
EGB_displayStart(ework,3,640,480) ;
EGB_color(ework,0,7) ;
EGB_color(ework,1,0) ;
EGB_color(ework,2,0) ;
EGB_clearScreen(ework) ;
EGB_fontStyle(ework,1) ;
EGB_textZoom(ework,0,16,16) ;
EGB_textZoom(ework,1,16,16) ;
EGB_paintMode(ework,0x20) ;
SND_init(swork) ;
SND_elevol_init() ;
SND_elevol_all_mute(0) ;
SND_elevol_set(1,127,127) ;
EGB_sjisString(ework,(char *)&msg[0]) ;
EGB_sjisString(ework,(char *)&msg[1]) ;
EGB_color(ework,0,3) ;
EGB_sjisString(ework,(char *)&msg[4]) ;
EGB_color(ework,0,7) ;
i = ext_malloc(buffer) ;
if (argc != 4)
freq = UPPER_FREQ ;
else
if ((freq = atoi(argv[3])) > UPPER_FREQ) {
EGB_color(ework,0,2) ;
EGB_sjisString(ework,(char *)&error[0]) ;
joy_wait() ;
free(buffer) ;
exit(9) ;
}
EGB_sjisString(ework,(char *)&msg[2]) ;
joy_wait() ;
WORD(para + 0) = 0 ;
WORD(para + 2) = 400 ;
WORD(para + 4) = 639 ;
WORD(para + 6) = 480 ;
EGB_rectangle(ework,para) ;
while(cdr_cdinfo(0,&cdtype,&strack,&etrack,&t_time[0],&d_time) & 0x80 != 0) {
EGB_color(ework,0,2) ;
EGB_sjisString(ework,(char *)&error[7]) ;
joy_wait() ;
EGB_rectangle(ework,para) ;
}
EGB_color(ework,0,7) ;
play_no = atoi(argv[1]) ;
if (play_no == 1 && (cdtype == 2 || cdtype == 3)) {
EGB_color(ework,0,2) ;
EGB_sjisString(ework,(char *)&error[1]) ;
EGB_sjisString(ework,(char *)&error[2]) ;
joy_wait() ;
free(buffer) ;
SND_end() ;
exit(9) ;
}
if (play_no > etrack) {
EGB_color(ework,0,2) ;
EGB_sjisString(ework,(char *)&error[3]) ;
joy_wait() ;
free(buffer) ;
SND_end() ;
exit(9) ;
}
start = t_time[play_no-1] ;
stop = t_time[play_no] ;
stop.min &= 0x7f ;
if ((stop.frame--) == 0x00) {
stop.frame = 74 ;
if ((stop.sec--) == 0x00) {
stop.sec = 59 ;
stop.min-- ;
}
}
strcpy(&snd.name[0],argv[2]) ;
snd.width = i ;
snd.loop_start = snd.loop_length = 0 ;
snd.flug = snd.dummy = 0 ;
snd.freq = freq * 0x62 ;
snd.fix = 0 ;
snd.onkai = (char)60 ;
cdr_mtplay(0,&start,&stop) ;
buff = 0 ;
do {
SND_pcm_rec(freq,buffer,i,0) ;
cdr_pause(0) ;
strcpy(s_name,argv[2]) ;
chr[0] = (char)('0' + buff / 10) ;
chr[1] = (char)('0' + buff % 10) ;
strcat(s_name,chr) ;
strcat(s_name,".snd") ;
fp = fopen(s_name,"wb") ;
fwrite(&snd,sizeof(char),32,fp) ;
if (fwrite(buffer,sizeof(char),i,fp) < i) {
EGB_color(ework,0,2) ;
EGB_sjisString(ework,(char *)&error[4]) ;
joy_wait() ;
fclose(fp) ; free(buffer) ; SND_end() ;
exit(9) ;
}
fclose(fp) ;
++buff ;
} while(cdr_continue(0) == 0) ;
free(buffer) ;
strcpy(s_name,argv[2]) ;
strcpy(s2_name,s_name) ;
strcat(s_name,"00") ;
strcat(s2_name,"01") ;
if (snd_adder(s_name,s2_name,w_name[0]) == 0) {
strcat(s_name,".snd") ; remove(s_name) ;
strcat(s2_name,".snd") ; remove(s2_name) ;
} else {
EGB_color(ework,0,2) ;
EGB_sjisString(ework,(char *)&error[5]) ;
joy_wait() ;
SND_end() ;
exit(9) ;
}
for (i=2; i<buff-1; i++) {
strcpy(s_name,argv[2]) ;
chr[0] = (char)('0' + i / 10) ;
chr[1] = (char)('0' + i % 10) ;
strcat(s_name,chr) ;
f1 = i % 2 + 1 ;
f2 = 2 - (i % 2) ;
if ((k = snd_adder(w_name[f1],s_name,w_name[f2])) == 0) {
strcat(s_name,".snd") ; remove(s_name) ;
strcpy(s_name,w_name[f1]) ; strcat(s_name,".snd") ;remove(s_name) ;
} else {
EGB_color(ework,0,2) ;
if (k != 2)
EGB_sjisString(ework,(char *)&error[6]) ;
else
EGB_sjisString(ework,(char *)&error[5]) ;
joy_wait() ;
SND_end() ;
exit(9) ;
}
}
EGB_sjisString(ework,(char *)&msg[3]) ;
joy_wait() ;
SND_end() ;
exit(0) ;
}